import axios from "axios";

export const getBaseUrl = () => process.env.REACT_APP_BASEURL;
export const getToken = () => (localStorage.token ? `Bearer ${localStorage.token}` : "");

export const request = axios.create({
    baseURL: getBaseUrl(),
    timeout: 60 * 1000,
    withCredentials: true,
});
// 拦截器在hook-useRequestInterceptor中实现，因为拦截器内需用到hook

// 清除缓存数据
export const clearAuthData = () => {
    localStorage.removeItem("token");
    localStorage.removeItem("user");
    localStorage.removeItem("allDictionary");
    localStorage.removeItem("allPermission");
};
